package com.ace3l.legal.gwt.domainmodule.domainxform;

import com.ace3l.legal.backend.domain.User;
import com.ace3l.legal.backend.domain.Role;
import com.ace3l.legal.gwt.domainmodule.gwt.GWTUser;
import com.ace3l.legal.gwt.domainmodule.gwt.GWTRole;

import java.util.Iterator;
import java.util.HashSet;

/**
 * Created by IntelliJ IDEA.
 * User: ageer
 * Date: Jul 22, 2008
 * Time: 11:29:09 AM
 * To change this template use File | Settings | File Templates.
 */
public class UserXForm {
    public static User fromGWT(GWTUser in) {
        if (in == null) return null;
        User myUser = new User();
        myUser.setPassword(in.getPassword());
        myUser.setUsername(in.getUsername());
        myUser.setId(in.getId());

        myUser.setRoles(RoleXForm.fromGWTList(in.getGWTRoles(),myUser));
        return myUser;
    }

    public static GWTUser toGWT(User in) {
        if (in == null) return null;
        GWTUser myUser = new GWTUser();
        myUser.setPassword(in.getPassword());
        myUser.setUsername(in.getUsername());
        myUser.setId(in.getId());
        myUser.setGWTRoles(RoleXForm.toGWTList(in.getRoles(),myUser));
        return myUser;
    }
}
